home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 3 / BBS in a box - Trilogy III.iso / Files / Prog / N-P / Pocket6.3 / Examples / Reader < prev    next >
Encoding:
Text File  |  1993-06-29  |  21.2 KB  |  522 lines  |  [TEXT/McSk]

  1. ( Reader application for Pocket Forth 0.6.3 )
  2. : RTEST ( -- ) key 13 = 0= IF bye ?terminal drop THEN  0 28 +md ! ;
  3. page
  4. ( *******************  W A R N I N G  ******************** )
  5. \   This file creates the ReadMe application. Do NOT run
  6. \ this file on a normal copy of Pocket Forth. Instead make
  7. \ a SPECIAL copy using ResEdit:
  8. \   1} Open a copy of ReadMe with ResEdit
  9. \   2} Delete the DICT 257 resource from ReadMe
  10. \   3} Open a copy of Pocket Forth with ResEdit
  11. \   4} Copy the DICT 257 resource from Pocket Forth
  12. \   5} Paste the DICT 257 resource into ReadMe
  13. \   6} Save ReadMe with ResEdit
  14. \   7} Quit ResEdit and Open ReadMe
  15. \   8} Type "open" and open Reader
  16. \   9} Press the return key, wait until ReadMe quits.
  17. \  10} Restart ReadMe.
  18. (  Type return to continue, anything else to quit. )  rtest
  19.  
  20. forget task : task ;
  21.  
  22. : !FONT ( n -- ) >r ,$ A887 ; macro  ( _TextFont )
  23. : !FSIZE ( n -- ) >r ,$ A88A ; macro  ( _TextSize )
  24. : !FACE ( face -- ) >r ,$ A888 ; macro ( _TextFace )
  25. : SFONT ( -- ) 0 !font  12 !fsize ;  ( 12 point Chicago )
  26. : NFONT ( -- ) 4 !font  12 !fsize ;  \ 12 point Monaco
  27. : LFONT ( -- ) nfont  9 !fsize ;     \  9 point Monaco
  28. : TFONT ( -- ) 20 !font 9 !fsize ;   \  9 point Times
  29. : CLS ( -- ) 4 +md a>r ,$ A8A3  20 20 !pen ;  ( CLear Screen )
  30.  
  31. ( old style colors )
  32. : BLACK    33 0 2>r ,$ A862 ;  ( black _ForeColor )
  33. : RED     205 0 2>r ,$ A862 ;  ( red _ForeColor )
  34. : BLUE    409 0 2>r ,$ A862 ;  ( blue _ForeColor )
  35. : YELLOW   69 0 2>r ,$ A863 ;  ( yellow _BackColor )
  36. : WITE     30 0 2>r ,$ A863 ;  ( white _BackColor )
  37.  
  38. ( rect words )
  39. : RECT ( compile: -- ) ( run: -- addr ) variable 6 allot ;
  40. : !RECT ( t l b r rect -- ) >r  swap r 4 + 2!  swap r> 2! ;
  41. : @RECT ( rect -- t l b r ) dup 2@ swap  rot 4 + 2@ swap ;
  42. : ROFFSET ( h v rect -- ) a>r 2>r ,$ A8A8 ;  ( _OffsetRect )
  43. : RINSET ( h v rect -- ) a>r 2>r ,$ A8A9 ;  ( _InsetRect )
  44. : ?EMPTY ( rect -- flag ) 0 >r a>r ,$ A8AE r> ;  ( _EmptyRect )
  45. : RERASE ( rect -- ) a>r ,$ A8A3 ;  ( _EraseRect )
  46.  
  47. : ?PHIT ( h v poly -- flag ) ( true if h,v is in polyBBox )
  48.     0 >r  2@ dl@  2 0 d+  2swap 2>r  2>r ,$ A8AD r> ;  ( _PtInRect )
  49. : POLYGON ( addr -- ) 0 0 2>r ,$ A8CB 2r> rot 2! ;  ( _OpenPoly )
  50.  
  51. ( print PICT resources from this file )
  52. : GETPICT ( id -- dhandle ) 0 0 2>r  >r  ,$ A9BC  2r> ;  ( _GetPict )
  53. : PDRAW ( rect dhandle -- ) ( draw a picture in rect )
  54.     2>r a>r ,$ A8F6 ;  ( _DrawPicture )
  55. : DPICT ( rect id -- ) getpict  pdraw ;
  56.  
  57. ( create and destroy pictures )
  58. : PICTURE ( rect -- dhandle ) ( open a picture )
  59.     0 0 2>r  a>r  ,$ A8F3 2r> ;  ( _OpenPicture )
  60. : PCLOSE ,$ A8F4 ; macro  ( _ClosePicture )
  61. : PKILL ( addr -- ) 2@ 2>r ,$ A8F5 ; ( _KillPicture at addr )
  62.  
  63. \ color availability testing
  64. : ?COLOR ( -- f ) \ true if color is available and system>6.0.4
  65.     ,s qd   ?gestalt dup IF  2drop 256 < 0= THEN ; 
  66. : GDEVICE ( -- dhandle ) \ handle of grafics device
  67.     0 0 2>r ,$ aa32 2r> ;  ( _getGDevice )
  68. : BITS/PIXEL ( -- n )  \ n = bit depth of monitor setting
  69.     ?color IF
  70.       gdevice  dl@ 22 s>d d+  \ handle of pixmap
  71.       dl@ dl@ 32 s>d d+  l@   \ get the pixsize
  72.     ELSE 1 THEN ;
  73.  
  74. ( icons )
  75. : CIGET ( id -- d.handle ) ( call once per icon )
  76.     0 0 2>r >r  \ push room and id
  77.     ?color IF ,$ AA1E      ( _GetCIcon )
  78.     ELSE ,$ A9BB  THEN 2r> ;  ( _GetIcon )
  79. : CIPLOT ( rect d.handle -- ) \ draw icon in rect
  80.     rot a>r 2>r
  81.     ?color IF ,$ AA1F  ( _PlotCIcon )
  82.     ELSE ,$ A94B  THEN ;  ( _PlotIcon )
  83.  
  84.  
  85. ( polygons for the 'NEXT' and 'PREV' "buttons" )
  86. 2variable APOLY  ( aft button poly handle  )
  87. 2variable FPOLY  ( fore button poly handle )
  88. : +APOLY ( -- ) apoly polygon
  89.     5 225 !pen 20 210 -to 50 210 -to
  90.     50 240 -to 20 240 -to  5 225 -to
  91.     ,$ A8CC ;  ( _ClosePgon )
  92. : +FPOLY ( -- ) fpoly polygon
  93.     440 225 !pen 425 210 -to 390 210 -to
  94.     390 240 -to  425 240 -to 440 225 -to
  95.     ,$ A8CC ;  ( _ClosePgon )
  96.  
  97. ( display "buttons" )
  98. : .POLY ( addr -- ) blue  2@ 2>r ,$ A8C6  black ;  ( _FramePoly )
  99. : .AARROW ( -- ) 015 230 !pen ." Prev"  apoly .poly ;
  100. : .FARROW ( -- ) 396 230 !pen ." Next"  fpoly .poly ;
  101. : .ARROWS ( -- ) .aarrow .farrow ;
  102.  
  103.  
  104. \ display icons
  105. variable ICONTABLE  0 iconTable !  12 allot   \ room for 2 icons
  106.     ( no.of.entries   id#1  handle#1  id#2  handle#2  )
  107. : >ICON ( index -- addr ) 6 * iconTable 2+ + ; \ icon list entry (0 based)
  108. : +ICON ( id -- ) \ loads icon from disk and stores data in table
  109.     iconTable @ >icon   \   get entry address
  110.     2dup !               \  store id into table
  111.     swap ciget rot 2+ 2!  \ get & store handle
  112.     1 iconTable +! ;
  113. : .ICON ( id rect -- ) \ display icon in rect
  114.     SWAP  iconTable @ 0 DO  \  search the icon table ..
  115.       r >icon @ over = IF    \ .. for the id wanted
  116.         drop  r >icon 2+ 2@  ciplot LEAVE
  117.     THEN  LOOP ;
  118.  
  119.  
  120. \ Flying Bird stuff
  121. rect BRECT  0 0 14 28 brect !rect  ( the bird's rect )
  122. rect OBRECT  0 0 0 0 obrect !rect  ( old brect )
  123. 2variable B1PICT  ( hold b1's pict handle )
  124. 2variable B2PICT  ( hold b2's pict handle )
  125. 2variable B3PICT  ( hold b3's pict handle )
  126.  
  127. ( draw the three bird positions )
  128. : .B1  red 2 0 !pen 6 0 -to 12 6 -to 18 0 -to 22 0 -to  black ;
  129. : .B2  red 0 6 !pen 24 6 -to black ;
  130. : .B3  red 2 12 !pen 6 12 -to 12 6 -to 18 12 -to 22 12 -to black ;
  131.  
  132. : +BIRD \ initialize the birds pictures & store the handles
  133.     brect picture .b1 pclose b1pict 2!
  134.     brect picture .b2 pclose b2pict 2!
  135.     brect picture .b3 pclose b3pict 2!
  136.     0 0 0 0 brect !rect  0 0 0 0 obrect !rect ;
  137. : -BIRD  b1pict pkill b2pict pkill b2pict pkill ;
  138.  
  139. : B1 brect b1pict 2@ pdraw ;
  140. : B2 brect b2pict 2@ pdraw ;
  141. : B3 brect b3pict 2@ pdraw ;
  142. create .BS  ' b1 ,  ' b2 ,  ' b3 ,  ( bird draw array )
  143. variable BTHIS  0 bthis !  ( offset to the current routine )
  144. 4 constant #BIRDS  \ (number_of_birds-1)*2
  145.  
  146. : THISBIRD ( -- n ) bthis @ ;  \   the current bird
  147. : NEXTBIRD ( -- ) 2 bthis +! ;  \  set bthis to the next bird
  148. : FIRSTBIRD ( -- ) 0 bthis ! ;   \ first picture in sequence
  149. : .BIRD ( n -- ) .bs + @  execute ;  \ draw bird n
  150.  
  151. : MOVEBIRD 3 -1 brect roffset ;  \  translate brect down1 for 3right
  152. : SHRINKBIRD 1 1 brect rinset ;   \ shrink brect by 2 pixels
  153.  
  154. : ANIMATE ( -- ) ( draw the flying red bird )
  155.     brect ?empty IF                   \ if bird has shrunk to oblivion...
  156.       48 291 60 309 brect !rect  THEN  \ ...restore its origonal size
  157.     bits/pixel 1 > IF yellow THEN
  158.     obrect rerase wite             \   erase the old rect
  159.     brect @rect obrect !rect        \  set old rect to current rect
  160.     0 -1 obrect rinset               \ expand old rect for full erasure
  161.     thisBird .bird                      ( draw the bird )
  162.     thisBird #birds < IF            \    if its bird 1 or 2
  163.       nextBird  moveBird             \   increment bird and move rect
  164.     ELSE                              \  its bird 3
  165.       firstBird moveBird shrinkBird    \ cycle, move & shrink )
  166.       2 >r ,$ A889  ( SrcXor _TextMode )
  167.  \    50 30 !pen ." NEW!   IMPROVED!"
  168.     THEN ;
  169.  
  170.  
  171. ( rects for pictures )
  172. rect PRECT   15  48 212 405 prect !rect  ( title picture rect )
  173. rect CRECT   15 181 210 405 crect !rect  ( title picture rect )
  174. rect SRECT  192 222 221 370 srect !rect  ( signature rect )
  175. rect IRECT  170 194 203 227 irect !rect  ( icon rect )
  176.  
  177. : SCR ( -- ) @pen swap drop 16 + 50 swap !pen ;  ( special cr )
  178. : BCR ( -- ) @pen swap drop 50 swap !pen ;  ( cr without lf )
  179.  
  180. ( P1 - P? are page drawing routines.  They have no stack effect.)
  181. : P1  cls  prect 4000 dpict
  182.     bits/pixel 1 > IF crect 4002 dpict
  183.     THEN  5 247 !pen tfont ." Read Me special edition." sfont
  184.     .farrow ;
  185.  
  186. : P2  cls scr
  187.     ."       Its FAST, its FUN and its FREE!" scr scr
  188.     ."    Its Pocket Forth, a programming language for" scr
  189.     ."  writing Macintosh applications and DAs." cr scr
  190.     ."    You can take advantage of many new features" scr
  191.     ."  in this release such as Apple Events*, Floating" scr
  192.     ."  Point, Gestalt** and Drag & Drop* programming." cr scr
  193.     ."    Learn Forth programming with the contents of" scr
  194.     ."  the Starting folder (inside the Extensions folder.)"
  195.     scr scr scr ."            * System 7   ** System 6.0.4+"
  196.     srect 4001 dpict  ( draw signature picture )
  197.     .arrows ;
  198.  
  199. : P3  cls scr
  200.     ."   Code produced by Pocket Forth is compact and fast." cr scr
  201.     ."   Pocket Forth produces true machine code, so" scr
  202.     ." you have complete control over your program." cr scr
  203.     ."   Examine and run the example and extension" scr
  204.     ." files for programming suggestions." cr scr
  205.     ."    If you have system 7 you can load text files by" scr
  206.     ."  dragging a text file icon onto Pocket Forth's icon." cr scr
  207.     ."  All systems can use the menu to “Open” a file."
  208.     143 392 176 425 irect !rect  ( set icon rect )
  209.     128 irect .icon  ( draw the icon )
  210.     .arrows ;
  211.  
  212. : P4  cls scr
  213.     ."   Print and read the Manual and the Glossary." cr scr
  214.     ."   The Manual consists of two TeachText documents" scr
  215.     ." suitable for use as a reference to Pocket Forth." cr scr
  216.     ."   The Glossary, also a TeachText document, is a" scr
  217.     ." list of the words in the Pocket Forth dictionary." scr
  218.     ." Stack effects, pronunciation and usage are shown." cr scr
  219.     ."   An addendum describes the desk accessory." cr scr
  220.     ."   Other document files abound." scr
  221.     .arrows ;
  222.  
  223. : P5  cls scr
  224.     ." Major changes since release 5:" scr scr
  225.     ."  • Floating point numbers!" cr scr
  226.     ."    Numeric input containing a decimal point is" scr
  227.     ."    interpreted as an extended floating point" scr
  228.     ."    number. Floating Point numbers are kept on" scr
  229.     ."    the stack as ten byte entities."  cr scr
  230.     ."    SANE is used along with three dozen new" scr
  231.     ."    words that manipulate floating point numbers." cr scr scr
  232.     ."                                ( continued ... )"
  233.     .arrows ;
  234.  
  235. : P6  cls scr
  236.     ." Floating point continued ..." cr scr
  237.     ."    Stack words:      "  2 !face
  238.                            ." fdrop   fdup   fswap   fpick" scr
  239.     ."                               fpack   froll   f>d   d>f" cr scr
  240.     0 !face ."    Memory words: " 2 !face ." f@   f!   fliteral   f," scr
  241.     ."                               fconstant   fvariable" cr scr
  242.     0 !face ."    I/O words:         " 2 !face
  243.                                     ." fnumber   sci   fix   f." cr scr
  244.     0 !face ."    Math words:      " 2 !face
  245.                                     ." fcompare   f+   f-   f*   f/" scr
  246.     ."                               frem   f^   fint   fabs   fsqrt" scr
  247.     ."                               fsin   fcos   ftan   fatn" scr
  248.     ."                               fexp   fln"  0 !face
  249.     .arrows ;
  250.  
  251.  
  252. : P7  cls scr
  253.     ."  • Apple Events:" cr scr
  254.     21 352 54 385 irect !rect  ( set icon rect )
  255.     128 irect .icon  ( draw the icon )
  256.     ."    Apple Events (System 7 required) are the" scr
  257.     ."    standard conduit for inter-application" scr
  258.     ."    communication. Pocket Forth programs may" scr
  259.     ."    define new Apple event handlers. The four" scr
  260.     ."    required events and all user defined events" scr
  261.     ."    are installed automatically when Pocket" scr
  262.     ."    Forth starts." cr scr
  263.     ."    Examples for HyperCard and Frontier are" scr
  264.     ."    in the 'Extensions:Apple Events' folder." cr scr
  265.     ."                                ( continued ... )"
  266.     .arrows ;
  267.  
  268.  
  269. : P8  cls scr
  270.     ." New words and variables control Apple Events:" cr scr
  271.     2 !face ."    AE:  " 0 !face ." and " 2 !face ." AE:  " 0 !face
  272.     ."    begin and end event definitions" scr
  273.     2 !face ."    ,S  " 0 !face
  274.     ."            compile (or stack) 4 bytes from ASCII" cr scr
  275.     2 !face  ."    +Md  " 0 !face ." variables:" scr
  276.     ."            136    Apple Event handler routine" scr
  277.     ."            188    Address of installation list" scr
  278.     ."            190    Error handler routine ("
  279.                          2 !face ." drop "  0 !face ." )" scr
  280.     ."            198    Reply record handle holder" scr
  281.     ."            202    Apple Event record handle"
  282.     .arrows ;
  283.  
  284. : P9  cls scr
  285.     ."  • Use " 2 !face ." ?gestalt  " 0 !face
  286.        ." to query the system." cr scr
  287.     ."    Using this new system trap, available since" scr
  288.     ."    late system 6, you can determine much about" scr
  289.     ."    the system software and hardware."  scr scr
  290.     ."  • A color conscious window is created if a" scr
  291.     ."    color machine is in use. This has no visual" scr
  292.     ."    effect but allows your programs to use color." scr scr
  293.     ."  • A new color icon and signature is used."
  294.     336 216 !pen  lfont ." p4TH" sfont
  295.     175 335 207 367 irect !rect  ( set icon rect )
  296.     129 irect .icon  ( draw the icon )
  297.     .arrows ;
  298.  
  299. : P10  cls scr
  300.     ." New for 6.3:" cr scr
  301.     ."  • The word \ makes comments more effecitve." cr scr
  302.     ."  • " 2 !face ." Warm  " 0 !face
  303.         ." restarts Pocket Forth, but leaves" scr
  304.     ."    the dictionary intact." cr scr
  305.     ."  • " 2 !face ." Depth  " 0 !face
  306.         ." lets you know how many items are" scr
  307.     ."    on the stack." scr scr
  308.     ."  • Check out the Balloon Help."
  309.     .arrows ;
  310.  
  311. : P11  cls scr
  312.     ." Bug fixes:" cr scr
  313.     ."  • The manual has been updated and now" scr
  314.     ."    prints with pictures, without errors." cr scr
  315.     ."  • " 2 !face ." Back  " 0 !face
  316.        ." now compiles correct branches." cr scr
  317.     ."  • A 32 bit address error in the update" scr
  318.     ."    routine has been fixed." cr scr
  319.     ."  • A new word, " 2 !face ." Bye  " 0 !face
  320.        ." does not use _ExitToShell." scr scr scr
  321.     ."                                ( continued ... )"
  322.     .arrows ;
  323.  
  324. : P12  cls scr
  325.     ." Bug fixes, continued ...       (New for 6.3)" cr scr
  326.     ."  • " 2 !face ." +LOOP  " 0 !face
  327.        ." now works correctly with" scr
  328.     ."    negative arguments." cr scr
  329.     ."  • " 2 !face ." TYPE  " 0 !face
  330.        ." does not end with a space." cr scr
  331.     ."  • " 2 !face ." QUIT  " 0 !face
  332.        ." leaves the stack untouched." cr scr
  333.     ."  • Tabs are now converted to spaces before" scr
  334.     ."    interpreting, so they no longer cause errors."
  335.     .arrows ;
  336.  
  337. : P13  cls scr
  338.     ." Notes:" cr scr
  339.     ."  • A DA version is now included. Version 1.6.3" scr
  340.     ."    includes all of the new features except for" scr
  341.     ."    Apple Events support." cr scr
  342.     ."  • " 2 !face ." Grow  " 0 !face
  343.        ." has been removed from the application." scr
  344.     ."    Allocated memory is 32K for both application" scr
  345.     ."    and DA." cr scr
  346.     ."  • Choosing “Save” from the menu confirms your" scr
  347.     ."    choice before overwriting the dictionary." cr scr
  348.     ."                                ( continued ... )"
  349.     .arrows ;
  350.  
  351. : P14  cls scr
  352.     ." Notes, continued ..." cr scr
  353.     ."  • 68040's instruction cache must be disabled" scr
  354.     ."    to correctly compile code." cr scr
  355.     ."  • The floating point interpreter will attempt" scr
  356.     ."    to convert any undefined token to a number." scr
  357.     ."    If the token begins with a number, it will" scr
  358.     ."    be converted causing unexpected results." cr scr
  359.     ."  • Numerous code tightening and speed up" scr
  360.     ."    enhancements have been made."
  361.     .arrows ;
  362.  
  363. : P15  cls scr
  364.     ." Packing list for Pocket Forth, release 6.3:" scr scr
  365.     ."  • The application, Pocket Forth version 0.6.3" scr
  366.     ."  • The desk accessory, PocketDA version 1.6.3" cr scr
  367.     ."  Text files:" scr
  368.     ."  • The Manual parts 1 and 2" scr
  369.     ."  • The Glossary of Pocket Forth words" scr
  370.     ."  • Source code with assembly instructions" scr
  371.     ."     and an assembly script for Frontier." scr
  372.     ."  • Source and Manual Addendum for the DA." cr scr scr
  373.     ."                                ( continued ... )"
  374.     .arrows ;
  375.  
  376. : P16  cls scr
  377.     ."  • Example folder:           (Packing list cont.)" cr scr
  378.     ."                                   create this application" bcr
  379.     ."      Reader" scr
  380.     ."                                   the guts of a text editor" bcr
  381.     ."      TextEdit" scr
  382.     ."                                   the Sieve of Erastothanes" bcr
  383.     ."      Sieve" scr
  384.     ."                                   demonstrate them" bcr
  385.     ."      Window&Menu" scr
  386.     ."                                   read and write ASCII data files" bcr
  387.     ."      DataFiles" scr
  388.     ."                                   floating point trig. functions" bcr
  389.     ."      SANETrig" scr
  390.     ."                                   16/32 bit math functions" bcr
  391.     ."      IntegerTrig" scr
  392.     ."                                   QuickDraw routines with demo" bcr
  393.     ."      Graphics" scr
  394.     ."                                   an RPN scientific calculator" bcr
  395.     ."      Calculator" cr scr scr
  396.     ."                                ( continued ... )"
  397.     .arrows ;
  398.  
  399. : P17  cls scr
  400.     ."  • Extension folder:          (Packing list cont.)" cr scr
  401.     ."                                    Make Pocket Forth mostly" bcr
  402.     ."      Starting folder" scr
  403.     ."                                    compatable with "
  404.                                           4 !face  ." Starting" bcr
  405.     nfont 2 !face ."     ATTENTION" 0 !face sfont scr
  406.     ."                                    " 4 !face  ." Forth"
  407.                                           0 !face  ."  by Leo Brodie!" bcr
  408.     nfont 2 !face ."      BEGINNERS!" 0 !face sfont cr scr
  409.     ."                                    A folder with new event" bcr
  410.     ."      Apple Events" scr
  411.     ."                                    definitions and interface files" scr
  412.     ."                                    for Frontier and HyperCard." cr scr
  413.     ."                                    A library of utility routines." bcr
  414.     ."      Misc" cr scr
  415.     ."                                    The Forth Vendors Group" bcr
  416.     ."      fvgFloatingPoint" scr
  417.     ."                                    floating point standard."
  418.     128 94 161 127 irect !rect  ( set icon rect )
  419.     128 irect .icon  ( draw the icon )
  420.     .arrows ;
  421.  
  422. : P18  cls scr
  423.     ."  • Extras folder:         (Disk packing list only)" cr scr
  424.     ."                                   test your esp with cards" bcr
  425.     ."      Rhine" scr
  426.     ."                                   create the Rhine application" bcr
  427.     ."      Rhiner" scr
  428.     ."                                   test random numbers" bcr
  429.     ."      RandomTest" cr scr
  430.     ."                                   use Frontier to revert a saved" bcr
  431.     ."      RevertDICT" scr
  432.     ."                                   Pocket Forth dictionary to its" scr
  433.     ."                                   default state"
  434.     .arrows ;
  435.  
  436. : P19  cls scr
  437.     ."     If you find a bug, need help, or want to talk" scr
  438.     ."    about this, write. I'd like to hear from you and" scr
  439.     ."    I'll attempt to answer your mail." cr scr
  440.     ."    Do not send any money, Pocket Forth is free!" cr scr
  441.     ."    Contact me at any of the following addresses:" scr
  442.     ."      CompuServe     [70566,1474]" scr
  443.     ."      AOL                   cheilman" scr
  444.     ."      Email                “heilman@pc.maricopa.edu”" scr
  445.     ."      U.S. Mail           PO box 8345" scr
  446.     ."                               Phoenix AZ 85066-8345"
  447.     .aarrow ;
  448.  
  449. \ page list
  450. variable PWHICH  0 pwhich !  ( page-1 to be drawn )
  451. 18 constant PNO  ( number of pages-1 )
  452. create PLIST  ( ordered list of routines or "pages" )
  453.     ' p1 ,  ' p2 ,  ' p3 ,  ' p4 ,
  454.     ' p5 ,  ' p6 ,  ' p7 ,  ' p8 ,
  455.     ' p9 ,  ' p10 , ' p11 ,  ' p12 ,
  456.     ' p13 ,  ' p14 ,  ' p15 ,  ' p16 ,
  457.     ' p17 ,  ' p18 ,  ' p19 ,
  458.  
  459. ( update, menu, button and idle handlers )
  460. : DOUP  pwhich @ 2* plist + @ execute ;  ( draw the pwhichth page )
  461. : DON ( n -- ) pwhich ! doup ;  ( go to nth page )
  462. : DOAFT  pwhich @ 1 - 0 max don ;  ( decrement pwhich )
  463. : DOFOR  pwhich @ 1+ pno min don ;  ( increment pwhich )
  464. : DOFIRST  0 don ;  ( go to first page )
  465. : DOLAST  pno don ;  ( go to last page )
  466. : DONEW 4 don ;  \ go to "whats new" page
  467. : DOBUG 10 don ;  \ go to "bug fixes" page
  468. : DONOTE 12 don ;  \ go to "notes" page
  469. : DOPACK 14 don ;   \ go to "packing list" page
  470.  
  471. : STOP  -bird bye ; ( stop animating )
  472.  
  473. \ menu list
  474. create GMENU ' dofirst , ' doaft , ' dofor , ' dolast ,
  475.    ' null ,  ' donew ,  ' dobug ,  ' donote ,  ' dopack ,  ' dolast ,
  476. create FMENU ' stop ,
  477. create MBAR fmenu ,  18 +md @ 2+ @ ,  gmenu ,
  478. 2variable GMENUH  0 0 gmenuh 2!  ( holder for goMenuHandle )
  479. ' beep  18 +md @  ( get pointer to menu list )
  480.         2+ @  ( get pointer to Edit menu from menu list )
  481.         8 + !  ( set paste handler to beep )
  482.  
  483. : +MENU ( -- ) ( Turn the new menu on.)
  484.     0 0 2>r 4 >r ,$ A9BF  ( _GetRMenu )
  485.     2r> 2dup 2>r 0 >r ,$ A935  ( _InsertMenu )
  486.     gmenuh 2!  ,$ A937 ;  ( _DrawMenuBar )
  487.  
  488. : DOBUTT  ( -- ) ( button handler )
  489.     @mouse apoly ?phit IF apoly 2@ 2>r ,$ A8C9 doaft ELSE
  490.       @mouse fpoly ?phit IF fpoly 2@ 2>r ,$ A8C9  dofor 
  491.     THEN  THEN ;
  492.  
  493. \ Idle procedure
  494. variable TLAST  0 tlast !  ( timer )
  495. 10 constant DELAY
  496. : TICKS ( -- n ) 364 0 l@ ;
  497. : ?TIME ( -- flags ) ( true if 1/delay seconds has elapsed )
  498.     ticks tlast @ - abs delay > ;
  499. : DOIDLE  ( do the first page animation )
  500.     pwhich @ 0= IF  ( if its the title page )
  501.       ?time IF ticks tlast !  animate
  502.     THEN  THEN ;
  503.  
  504. \ startup procedure
  505. : START  sfont   \ Set to 12 point Chicago font in srcCopy mode.
  506.     +apoly +fpoly       \    This is stuff that must
  507.     +menu  +bird         \   be set up at runtime,
  508.     128 +icon  129 +icon  \  because it uses handles.
  509.     BEGIN ?terminal drop AGAIN ;  ( event loop )
  510.  
  511. \ This is event handlers and data to set up when this is loaded.
  512. ' doup    14 +md !  \ set update handler
  513. ' dobutt  16 +md !  \ set button handler
  514.   mbar    18 +md !  \ set the menu handlers
  515. ' doidle  20 +md !  \ set idle handler
  516. ' stop    22 +md !  \ set quit handler
  517. ' start   26 +md !  \ set startup handler
  518. ' null   136 +md !  \ disable Apple Events
  519. 450 250   8 +md 2!  \ set window size
  520.  
  521. save  bye
  522.